﻿@model Hospital
@{
    ViewBag.Title = "编辑医院信息";
    Layout = "~/Views/Shared/Master.cshtml";
}
@{Html.Telerik().Window().Name("HospitalEditWindow").Title("编辑医院信息").HtmlAttributes(new { @class = "ContentWindow" })
    .Buttons(buttons => buttons.Clear())
    .Content(
@<text>
@{using (Ajax.BeginForm<HospitalController>(c => c.HospitalEdit((Hospital)null),
    new AjaxOptions { OnBegin = "BeforeSend", OnSuccess = "OnSuccess", OnFailure = "OnError" }))
  {
      @Html.HiddenFor(model => model.ID)
<table>
    <tr>
        <th>医院编号</th>
        <td>@Html.DisplayFor(model => model.Code)</td>
    </tr>
    <tr>
        <th>医院名称</th>
        <td>@Html.TextBoxFor(model => model.Name)</td>
    </tr>
    <tr>
        <th>地址</th>
        <td>@Html.TextBoxFor(model => model.Address)</td>
    </tr>
    <tr>
        <th>联系电话</th>
        <td>@Html.TextBoxFor(model => model.Phone)</td>
    </tr>
    <tr>
        <th>E-mail</th>
        <td>@Html.TextBoxFor(model => model.Email)</td>
    </tr>
    <tr>
        <th>网址</th>
        <td>@Html.TextBoxFor(model => model.Website)</td>
    </tr>
    <tr>
        <th>详细介绍</th>
        <td>@Html.TextAreaFor(model => model.Detail)</td>
    </tr>
</table>
<input type="submit" value="提交" />
  }
}
</text>)
    .Render();
}
@{Html.Telerik().Window().Modal(true).Visible(false)
    .Name("saving").Title("系统提示")
    .Buttons(buttons => buttons.Clear())
    .ClientEvents(window => window.OnOpen("OnSavingOpen"))
    .Content(
@<text>
正在保存，请稍后...
</text>)
    .Render();
}
@{Html.Telerik().Window().Modal(true).Visible(false)
    .Name("saveSuccess").Title("系统提示")
    .Buttons(buttons => buttons.Clear())
    .ClientEvents(window => window.OnOpen("OnSaveSuccessOpen"))
    .Content(
@<text>
保存成功！
</text>)
    .Render();
}
@{Html.Telerik().Window().Modal(true).Visible(false)
    .Name("saveError").Title("系统提示")
    .Buttons(buttons => buttons.Close())
    .ClientEvents(window => window.OnOpen("OnSaveErrorOpen"))
    .Content(
@<text>
出现错误，请重试！
</text>)
    .Render();
}
<script type="text/javascript">
    function OnSavingOpen() {
        $("#saving").data("tWindow").center();
    }
    function OnSaveSuccessOpen() {
        $("#saveSuccess").data("tWindow").center();
    }
    function OnSaveErrorOpen() {
        $("#saveError").data("tWindow").center();
    }
    function BeforeSend() {
        $("#saving").data("tWindow").open();
    }
    function OnSuccess(data) {
        if (data.ID) {
            $("#ID").val(data.ID);
            $("#saveSuccess").data("tWindow").open();
            $("#saving").data("tWindow").close();
            window.location = "@(Url.Action<HomeController>(c => c.Index()))";
        } else {
            $("#saveError").data("tWindow").open();
            $("#saving").data("tWindow").close();
        }
    }
    function OnError() {
        $("#saveError").data("tWindow").open();
        $("#saving").data("tWindow").close();
    }
</script>